package com.qf.controller;

import com.qf.entity.TbStudent;
import com.qf.service.TbStudentService;
import com.qf.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.annotation.MultipartConfig;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * @author 10202
 * @version V1.0
 * @Project management-system
 * @Package com.qf.controller
 * @Date 2023/5/21 10:21
 */
@RestController
@RequestMapping("/student/")
@MultipartConfig
public class StudentController {
    private final TbStudentService studentService;

    public StudentController(TbStudentService studentService) {
        this.studentService = studentService;
    }


    @PostMapping("login")
    public Result login(@RequestBody TbStudent student){
        return studentService.login(student.getSnum(),student.getSpassword());
    }
    @PostMapping("updatePassword")
    public Result updatepassword(@RequestBody TbStudent tbStudent)
    {
        return studentService.updatepassword(tbStudent);
    }

    @PostMapping("sendEmail")
    public Result sendEmail(){
        return Result.success("发送成功");
    }

    @GetMapping("getAssignmentList")
    public Result getAssignmentList(Long pageNum,Long pageSize,Long id){
        return studentService.getList(pageNum,pageSize,id);
    }


    @DeleteMapping("/deleteStudentListById")
    public Result deleteStudentListById(Long id){

        return studentService.deleteStudentListById(id);
    }

    @PutMapping("/updateStudentListById")
    public Result updateStudentListById(@RequestBody TbStudent tbStudent){
        return studentService.updateStudentListById(tbStudent);
    }

    @GetMapping("findAllStudents")
    public Result findAllStudents(){


        return  studentService.findAllStudents();
    }

    @GetMapping("downloadFile")
    public Result downloadFile(String studentid, HttpSession session, HttpServletResponse response){

        return studentService.downLoad(studentid,session,response);
    }









}
